home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / lang / c--ex101 / system / xms.c-- < prev   
Text File  |  1993-11-30  |  2KB  |  62 lines

  1. /*
  2.     SPHINX C-- example program
  3.     NAME:  XMS.C--
  4.     DESCRIPTION:  This program gives an example of some of the Extended
  5.                   Memory Standard (XMS) procedures available from C--.
  6.                   An XMS driver (such as QEMM.SYS, HIMEM.SYS or 386MAX.SYS)
  7.                   supporting version 2.0 or greater of the XMS standard is
  8.                   required.
  9. */
  10.  
  11. ?print "Building XMS.COM, the XMS example program.\n"
  12.  
  13. ?include "WRITE.H--"
  14. ?include "DOS.H--"
  15.  
  16. byte moveok = "EMB Move was OK!\n";
  17.  
  18. ?define SIZE_OF_BLOCK 100   /* size of block to allocate, in K bytes */
  19.  
  20.  
  21. main ()
  22. word EMBhandle;
  23. {
  24. WRITELN();
  25. IF( XMSgetversion() < 0x0200 )
  26.     {WRITESTR("XMS driver 2.0 or greater required.\n");
  27.     EXIT(-1);}
  28. ELSE WRITESTR("XMS driver detected.\n");
  29.  
  30. displayavailableEMB();
  31.  
  32. IF( XMSallocateEMB(SIZE_OF_BLOCK) == 0 )
  33.     {WRITESTR("Error allocating EMB of 100K size.\n");
  34.     EXIT(-1);}
  35. WRITESTR("100K EMB allocated OK!\n");
  36. EMBhandle = DX; 
  37.  
  38. displayavailableEMB();
  39.  
  40. IF( XMSmoveEMB(0,0,EMBhandle, DS,#moveok,0, 0,12) == 1) 
  41.     WRITESTR(#moveok);  // should display "EMB Move was OK!\n";
  42. IF( XMSmoveEMB(DS,#moveok+1,0, 0,0,EMBhandle, 0,12) == 1) 
  43.     WRITESTR(#moveok);  // should now display "EEMB Move wasOK!\n";
  44. XMSfreeEMB( EMBhandle );
  45.  
  46. WRITESTR("XMS demo finished.\n");
  47. }
  48.  
  49.  
  50. void displayavailableEMB ()
  51. word largestEMB,totalEMB;
  52. {largestEMB = XMSqueryfreeEMB();
  53. totalEMB = DX;
  54. WRITESTR("Largest free EMB available is: ");
  55. WRITEWORD(largestEMB);
  56. WRITESTR("K\n");
  57. WRITESTR("Total amount of free EMB available is: ");
  58. WRITEWORD(totalEMB);
  59. WRITESTR("K\n");
  60. }
  61.  
  62. /* end of XMS.C-- */